<script setup>
import {ref, reactive, onMounted} from "vue";
import {useRouter, useRoute} from "vue-router";

const phone = ref("login-tab-active");
const account = ref("login-tab")
const router = useRouter();

const changePhone = () => {
  phone.value = "login-tab-active";
  account.value = "login-tab";
  router.push("/user/login/loginByPhone");
};
const changeAccount = () => {
  phone.value = "login-tab";
  account.value = "login-tab-active";
  router.push("/user/login/loginByAccount");
};
const register = () => {
  router.push("/user/register");
}

const changeHome = () => {
  router.push("/");
}

router.push('/user/login/loginByPhone');
</script>
<template>
  <div class="min-h-screen bg-gray-50">
    <header class="header cursor-pointer">
      <div class="header-left">
        <img src="http://192.168.137.100:9000/other/logo.png" alt="logo" class="logo" @click="changeHome"/>
      </div>
      <div class="header-right">
        <span>联系客服</span>
        <span>帮助中心</span>
      </div>
    </header>

    <main class="main">
      <div class="content">
        <div class="illustration">
          <img
              src="http://192.168.137.100:9000/other/illustration.png"
              alt="登录页插画"
              class="illustration-img"
          />
        </div>

        <div class="login-container">
          <div class="login-tabs">
            <button @click="changePhone()" :class="phone">短信登录</button>
            <button @click="changeAccount()" :class="account">账号登录</button>
          </div>
          <div class="form">
            <router-view></router-view>
            <div class="register">还没有账号？<span @click="register()">免费注册</span></div>
          </div>
        </div>
      </div>
    </main>
  </div>
</template>

<style scoped>
/* 通用布局 */
.header {
  height: 4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.header-left .logo {
  height: 2rem;
}

.header-right {
  display: flex;
  gap: 1rem;
}

.main {
  display: flex;
  justify-content: center;
  padding: 3rem 1rem;
}

.content {
  display: flex;
  width: 100%;
  max-width: 72rem;
}

.illustration {
  flex: 1;
  padding-right: 3rem;
}

.illustration-img {
  width: 100%;
  object-fit: cover;
}

.login-container {
  width: 25rem;
  background: white;
  border-radius: 0.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  padding: 2rem;
}

.login-tabs {
  display: flex;
  margin-bottom: 1.5rem;
}

.login-tab,
.login-tab-active {
  flex: 1;
  text-align: center;
  padding: 0.5rem 0;
  font-weight: 500;
  border-left: none;
  border-right: none;
  border-top: none;
  border-bottom: 2px solid #e5e7eb;
  color: #6b7280;
  cursor: pointer;
}

.login-tab:hover,
.login-tab-active:hover {
  background: #e5e7eb;
}

.login-tab-active {
  border-bottom-color: #3b82f6;
  color: #3b82f6;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  height: 300px;
}

.register {
  text-align: center;
  font-size: 0.875rem;
  color: #9ca3af;
}

.register span {
  color: #3b82f6;
  cursor: pointer;
}
</style>
